/**
 * 
 */
package com.iot.ic.modules.model;

/**
 * @author Administrator
 *
 */
public class Pager {
	private Integer page  = 1 ; 
	private Integer pageSize = 10 ;
	private Integer totalPage = 1  ; //总页数 
	private Integer total ;  // 总记录数
	
	public Pager(Integer page , Integer pageSize){
		super();
		this.page = page ; 
		this.pageSize = pageSize ; 
	}
	
	public Pager(String page, String pageSize,Integer total) {
		super();
		this.page = Integer.parseInt(page);
		this.pageSize = Integer.parseInt(pageSize);
		this.total =total;
	}
	
	public Integer getFirstResult(){
		return pageSize*(page-1);
	}
	
	public Integer getPage() {
		return page;
	}
	public void setPage(Integer page) {
		this.page = page;
	}
	public Integer getPageSize() {
		return pageSize;
	}
	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
	}
	public Integer getTotalPage() {
		return totalPage;
	}
	public void setTotalPage(Integer totalPage) {
		if(totalPage==0){
			this.totalPage = 1 ; 
		}
		this.totalPage = totalPage;
	}
	public Integer getTotal() {
		return total;
	}
	public void setTotal(Integer total) {
		this.total = total;
		
		//计算总页数
		int _page = total/pageSize ; 
		int _plus = total%pageSize == 0 ?0 : 1 ; 
		this.totalPage = _page + _plus ; 
	}
	
}	
